package sz.szsmk.citizencard.ui.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chenenyu.router.annotation.Route;
import com.google.gson.Gson;

import sz.szsmk.citizencard.R;
import sz.szsmk.citizencard.model.network.bean.response.IUserInfo;
import sz.szsmk.citizencard.ui.base.IBaseActivity;
import sz.szsmk.citizencard.util.ACache;
import sz.szsmk.citizencard.util.Constant;
import sz.szsmk.citizencard.util.JumpUtils;

/**
 * Copyright (c)2019
 * author: zdh
 * created on: 2019/1/18 16:17
 * description:
 */
@Route("GesPsdActivity")
public class GesPsdActivity extends IBaseActivity implements View.OnClickListener {
    ImageView back;
    TextView settingTitle;
    RelativeLayout modifyPsd;
    RelativeLayout findPsd;

    @Override
    protected int attachLayoutRes() {
        return R.layout.gespsd_activity;
    }

    @Override
    protected void initInjector() {

    }
    private String userPhone;
    @Override
    protected void initViews() {

        back = findViewById(R.id.back);
        back.setOnClickListener(this);
        settingTitle = findViewById(R.id.setting_title);
        modifyPsd = findViewById(R.id.modify_psd);
        modifyPsd.setOnClickListener(this);
        findPsd = findViewById(R.id.find_psd);
        findPsd.setOnClickListener(this);


        settingTitle.setText("手势密码");
        String userinfo = ACache.get(this).getAsString("userinfo");
        IUserInfo.UserExBean mUserInfo = new Gson().fromJson(userinfo, IUserInfo.UserExBean.class);
//        IUserInfo.UserExBean userEx = mUserInfo.getUserEx();
        if (mUserInfo != null) {
            userPhone = mUserInfo.getMobile();
        } else {
        }

    }

    @Override
    protected void updateViews() {

    }


    public void onViewClicked(View view) {
        int id = view.getId();
        if (id == R.id.back) {
            finish();
        } else if (id == R.id.modify_psd) {
            Bundle bundle = new Bundle();
            bundle.putString("url", "gesPasswordSettingActivity");
            bundle.putBoolean("isNeedVaild", false);
            bundle.putString(Constant.TYPE, "set");
            JumpUtils.jumptoNatvie(GesPsdActivity.this, "gestureLoginActivity", 0, bundle);
        } else if (id == R.id.find_psd) {
            Bundle bundle1 = new Bundle();
            bundle1.putString("type", "resetGes");
            bundle1.putString("userPhone", userPhone);
            bundle1.putString("codeType", "10");
            JumpUtils.jumptoNatvie(this, "checkCode", 0, bundle1);
        }
    }

    @Override
    public void onClick(View v) {
        onViewClicked(v);
    }
}
